package com.study.创造型模式.单例模式.枚举;

public class Singleton8 {

    public static void main(String[] args) {
        System.out.println("使用枚举完成单例模式");

        Singleton instance = Singleton.INSTANCE;
        Singleton instance2 = Singleton.INSTANCE;
        System.out.println(instance == instance2);
        Singleton.sayOK();
    }
}


enum Singleton{
    INSTANCE ; //属性
    public static void sayOK(){
        System.out.println("ok");
    }
}
